package com.si.sea_island.config;//package com.zc.zc_service.config;
//
//import org.springframework.context.annotation.Configuration;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.Arrays;
//import java.util.HashSet;
//import java.util.Set;
//
//@WebFilter("/*")
//@Component
//@Configuration
//public class CORSFilter implements Filter {
//    public CORSFilter() {
//    }
//
//    public void destroy() {
//    }
//
//    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
//        //设置跨域请求
//        HttpServletRequest request = (HttpServletRequest) req;
//        HttpServletResponse response = (HttpServletResponse) res;
////        String[] allowDomains = {"http://www域名1","www域名1http://www域名2"};
////        Set allowOrigins = new HashSet(Arrays.asList(allowDomains));
////        String originHeads = request.getHeader("Origin");
////        if(allowOrigins.contains(originHeads)){
//            response.setHeader("Access-Control-Allow-Origin", "*");
//            response.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,DELETE,HEAD,PUT,PATCH");
//            response.setHeader("Access-Control-Max-Age", "36000");
//            response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept,Authorization,authorization");
//            response.setHeader("Access-Control-Allow-Credentials","true");
////        }
//        chain.doFilter(req, response);
//    }
//
//    public void init(FilterConfig fConfig) throws ServletException {
//    }
//}